import request from '../request/index.js'
//获取地址列表
export function listAddress() {
    let url  = '/api/order/address'
    return request.get(url)
}

//更新地址
export function mergeAddress(address) {
    let url = '/api/order/address'
    let data =  address
    data.Loading = true
    return request.post(url,data)
}

//获取地址
export function getAddress(id) {
    let url = '/api/order/address/info'
    let params = {id}
    return request.get(url,{params})
}

//移除地址
export function removeAddress(id) {
    let url = '/api/order/address/remove'
    let params = {id}
    return request.get(url,{params})
}

//提交订单
export function commitOrder(address,desc,orderType,payWay) {
    let url = '/api/order/cart/commit'
    let data = {address,desc,orderType,payWay}
    data.Loading = true
    return request.post(url,data)
}

//查询订单
export function listOrder(page) {
    let url = '/api/order/list'
    let limit  = 10
    let params = {page,limit}
    return request.get(url,{params})
}

//获取订单
export function getOrder(id,orderNo) {
    let url = '/api/order/info'
    let params = {id,orderNo}
    return request.get(url,{params})
}

//移除订单
export function removeOrder(orderId) {
    let url = '/api/order/remove'
    let data = {orderId}
    return request.post(url,data)
}

//统一下单
export function unionPay(orderNo) {
    let url = '/api/order/wx/union'
    let data = {orderNo}
    data.Loading = true
    return request.post(url,data)
}